package com.csx.saas.platform.init.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.csx.basic.base.service.SuperCacheServiceImpl;
import com.csx.basic.cache.model.CacheKeyBuilder;
import com.csx.basic.utils.CollHelper;
import com.csx.saas.common.cache.init.InitIndustryCacheKeyBuilder;
import com.csx.saas.platform.init.dao.InitIndustryMapper;
import com.csx.saas.platform.init.entity.InitIndustry;
import com.csx.saas.platform.init.service.InitIndustryService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.aop.framework.AopContext;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.Map;
import java.util.Set;

/**
 * <p>
 * 业务实现类
 * 行业
 * </p>
 *
 * @author ChenSongXin
 * @date 2021-03-03
 */
@Slf4j
@Service
@DS("#thread.tenant")
public class InitIndustryServiceImpl extends SuperCacheServiceImpl<InitIndustryMapper, InitIndustry> implements InitIndustryService {

    @Override
    protected CacheKeyBuilder cacheKeyBuilder() {
        return new InitIndustryCacheKeyBuilder();
    }

    protected InitIndustryService currentProxy() {
        return ((InitIndustryService) AopContext.currentProxy());
    }

    @Override
    public Map<Serializable, Object> findInitIndustryNameByIds(Set<Serializable> ids) {
        return CollHelper.uniqueIndex(findByIds(ids,this::listByIds), InitIndustry::getId, industry -> industry.getName());
    }
}
